package com.maoatao.easycodegen.framework.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.function.Function;

/**
 * SimplePagination implementation
 *
 * @author MaoAtao
 * @date 2025-10-04
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Pagination<T> {

    private List<T> records;
    private long total;
    private long size;
    private long current;

    public <R> Pagination<R> convert(Function<T, R> converter) {
        List<R> mappedRecords = records.stream().map(converter).toList();
        return new Pagination<>(mappedRecords, total, size, current);
    }

}
